package com.gzc.just.play.last.war.sceneserver.gameobject.base;

/**
 * 游戏对象阵营枚举
 * 
 * 对应C++ EGameObjectCamp
 * 
 * @author AI Assistant
 * @version 1.0.0
 * @since 2025-11-22
 */
public enum GameObjectCamp {
    NEUTRAL(0, "中立"),     // 中立阵营
    TEAM_1(1, "队伍1"),     // 队伍1（蓝方）
    TEAM_2(2, "队伍2"),     // 队伍2（红方）
    NPC(3, "NPC"),          // NPC阵营
    MONSTER(4, "野怪"),     // 野怪阵营
    UNKNOWN(-1, "未知");    // 未知阵营

    private final int code;      // 阵营编码
    private final String name;   // 阵营名称

    GameObjectCamp(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据编码获取阵营
     */
    public static GameObjectCamp fromCode(int code) {
        for (GameObjectCamp camp : GameObjectCamp.values()) {
            if (camp.code == code) {
                return camp;
            }
        }
        return UNKNOWN;
    }

    /**
     * 检查两个阵营是否是敌方
     */
    public static boolean isEnemy(GameObjectCamp camp1, GameObjectCamp camp2) {
        if (camp1 == null || camp2 == null) {
            return false;
        }
        // 中立和NPC/野怪不是敌方
        if (camp1 == NEUTRAL || camp2 == NEUTRAL) {
            return false;
        }
        if (camp1 == NPC || camp2 == NPC) {
            return false;
        }
        if (camp1 == MONSTER || camp2 == MONSTER) {
            return false;
        }
        // 不同队伍才是敌方
        return camp1 != camp2;
    }

    /**
     * 检查两个阵营是否是友方
     */
    public static boolean isFriendly(GameObjectCamp camp1, GameObjectCamp camp2) {
        if (camp1 == null || camp2 == null) {
            return false;
        }
        return camp1 == camp2;
    }
}
